package com.cropdoctor.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cropdoctor.model.dto.PostDto;
import com.cropdoctor.model.po.PostPo;
import com.cropdoctor.model.vo.PostVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PostMapper extends BaseMapper<PostPo> {
    List<PostVO> selectToVO();

    PostDto selectPostInfo(@Param("id") long idPost);

    @Update("update post_table set like_number = like_number + 1 where id = #{idPost}")
    int increaseLikeNumber(long idPost);

    @Update("update post_table set like_number = like_number - 1 where id = #{idPost}")
    int decreaseLikeNumber(long idPost);
}
